Field (computer science)

In computer science, data that has several parts can be divided into fields. Relational databases arrange data as sets of database records, also called rows. Each record consists of several fields; the fields of all records form the columns.

In object-oriented programming, field (also called data member or member variable) is the data encapsulated within a class or object. In the case of a regular field (also called instance variable), for each instance of the object there is an instance variable: for example, an Employee class has a Name field and there is one distinct name per employee. A static field (also called class variable) is one variable, which is shared by all instances.[1]

Contents

Fixed length

Fields that contain a fixed number of bytes are known as fixed length fields. A four byte field for example may contain a 31 bit binary integer plus a sign bit (32 bits in all). A 30 byte name field may contain a persons name typically padded with blanks at the end. The disadvantage of using fixed length fields is that some part of the field may be wasted but space is still required for the maximum length case. Also, where fields are ommitted, padding for the missing fields is still required to maintain fixed start positions within a record for instance.

Variable length

A variable length field may sometimes consist of two components:-

Processing variable fields of this type is generally much faster than other formats since it is not necessary to parse the input to determine the beginning of the next field.

Alternatively, fields of variable length may, for instance, be separated by commas (see Comma-separated values) when the end of each individual field must be determined by scanning for the delimiter "one byte at a time". Missing fields can be identified by two or more consecutive commas. It is not possible to use comma separated fields for exclusively binary fields since particular binary strings may be misinterpreted as a comma delimiter although unique binary values could be used instead, provided they do not occur naturally within the string.

See also

References